<?php
/**
 * 图书章节管理数据模型
 * @author sandy_office
 *
 */
class chapterModel extends Model{
	
	/**
	 * 获取指定图书章节信息
	 */
	public function get_book_chapter($book_id){
		$book_id = intval($book_id);
		if (!$book_id) {
			return false;
		}
		
		
		$sql = "SELECT chapter_id,chapter_title,book_id,sort 
				FROM #__chapter WHERE book_id = $book_id  
				ORDER BY sort DESC, chapter_id ASC";

		$this->db->set_query($sql);
		
		return $this->db->get_all();
	}
	
	
	/**
	 * 获取章节信息
	 * 
	 * @param int $chapter_id 
	 */
	public function get_chapter($chapter_id){
		$sql  = "SELECT * FROM #__chapter WHERE chapter_id = $chapter_id";
		$this->db->set_query($sql);
		
		return $this->db->get_row();
	}

}